package com.ly.pj.module.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class ModuleController {//代表任意一个模块的Controller

    @RequestMapping("/doCompute/{n1}/{n2}")
    @ResponseBody
    public String doCompute(@PathVariable Integer n1 , @PathVariable Integer n2) {
        //try {
            Integer result = n1 / n2;
            return "result=" + result;
        //} catch (java.lang.ArithmeticException e) {
            //e.printStackTrace();
            //return e.getMessage();
            //log.info("exception{}",e.getMessage());
          //  return "除数不能为0";
        //}
        //思考：一个Controller类可能会有很多方法，每个方法都会出异常假如没有每个方法都要进行try catch就会有
    }
}
